package io.adrainty.bolee.insurance.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.adrainty.bolee.framework.commons.basic.ResponseCode;
import io.adrainty.bolee.framework.commons.exception.AppException;
import io.adrainty.bolee.insurance.models.entity.ConditionEntity;
import io.adrainty.bolee.insurance.repository.IConditionRepository;
import io.adrainty.bolee.insurance.service.IConditionService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>ConditionServiceImpl</p>
 *
 * @author AdRainty
 * @version V1.0.0
 * @description 筛选项管理
 * @since 2025/8/11 11:20:49
 */

@Service
public class ConditionServiceImpl implements IConditionService {

    @Resource
    private IConditionRepository conditionRepository;

    @Override
    public IPage<ConditionEntity> findConditionPage(Integer pageNum, Integer pageSize, ConditionEntity searchDTO) {
        return conditionRepository.findConditionPage(pageNum, pageSize, searchDTO);
    }

    @Override
    public List<ConditionEntity> findConditionList(ConditionEntity entity) {
        return conditionRepository.findConditionList(entity);
    }

    @Override
    public ConditionEntity createCondition(ConditionEntity entity) {
        if (!conditionRepository.createCondition(entity)) {
            throw new AppException(ResponseCode.CONDITION_CREATE_ERROR);
        }
        return entity;
    }

    @Override
    public Boolean updateCondition(ConditionEntity entity) {
        if (entity.getId() == null) {
            throw new AppException(ResponseCode.ILLEGAL_PARAMETER);
        }
        return conditionRepository.updateCondition(entity);
    }

    @Override
    public Boolean deleteCondition(List<String> deleteIdList) {
        return conditionRepository.deleteCondition(deleteIdList);
    }
    
}
